package com.driving.code.controller;


import com.driving.code.entity.Grade;
import com.driving.code.entity.TUser;
import com.driving.code.service.GradeService;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 喜欢编程的代先生
 * @since 2021-06-14
 */
@RestController
@RequestMapping("/grade")
public class GradeController {

    @Resource
    private GradeService gradeService;

    @RequestMapping("/insertGrade")
    public String insertGrade(HttpSession session, Grade grade){
        TUser user = (TUser) session.getAttribute("user");
        grade.setGradeLearner(user.getUserId());
        boolean save = gradeService.save(grade);
        if (save){
            return "成绩已被记录";
        }
        return "成绩保存失败";
    }
}

